import {http} from "@/utils/request"
import type {loginResp} from "@/api/user/type";

//登录接口
export const reqLogin = (userinfo: any) => http<loginResp>({
    url: "/login",
    data: userinfo,
    method: "POST"
});
//退出接口
export const reqLogout = () => http({
    url: "/logout",
    method: "POST"
});
//获取验证码
export const reqGetCode = (email: any) => http({
    url: "/email",
    data: {
        'email': email
    },
    method: "POST"
});
//注册接口
export const reqRegister = (userinfo: any) => http({
    url: "/register",
    data: userinfo,
    method: "POST"
});
//获取用户信息
export const reqGetUserInfo = (token: String) => http({
    url: "/sxg/sxg_user/info",
    method: "GET",
    header: {"authorization": token}
});
//修改用户信息
export const reqChangeUserInfo = (userinfo: any) => http({
    url: "/sxg/sxg_user",
    data: userinfo,
    method: "PUT",
});
//获取用户收藏
export const reqUserCollection = (info: any) => http({
    url: "/sxg/sxg_goods_collection/page",
    data: info,
    method: "GET",
});
//取消商品收藏
export const reqRemoveUserCollection = (info: any) => http({
    url: "/sxg/sxg_goods_collection",
    data: info,
    method: "DELETE",
});
//修改商品收藏
export const reqSaveUserCollection = (info: any) => http({
    url: "/sxg/sxg_goods_collection",
    data: info,
    method: "POST",
});
//获取用户收货地址列表
export const reqUserAddress = () => http({
    url: "/sxg/sxg_address/list",
    method: "GET",
});
//新增用户收货地址
export const reqSaveAddress = (info: any) => http({
    url: "/sxg/sxg_address",
    data: info,
    method: "POST",
});
//删除用户收货地址
export const reqRemoveAddress = (info: any) => http({
    url: "/sxg/sxg_address",
    data: info,
    method: "DELETE",
});
//查询用户默认用户地址
export const reqGetDefaultAddress = () => http({
    url: "/sxg/sxg_address/default",
    method: "GET",
});
//设置用户默认用户地址
export const reqSetDefaultAddress = (info: any) => http({
    url: "/sxg/sxg_address/default",
    data: info,
    method: "POST",
});
//根据id查询用户收货地址
export const reqSelectById = (id: any) => http({
    url: "/sxg/sxg_address/" + id,
    method: "GET",
});
//修改用户收货地址
export const reqModifyById = (info: any) => http({
    url: "/sxg/sxg_address",
    data: info,
    method: "PUT",
});
//修改用户密码
export const reqModifyPassword = (info: any) => http({
    url: "/sxg/sxg_user/modifyPassword",
    data: info,
    method: "POST",
});
